<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\Adminuser;
/* @var $this yii\web\View */
/* @var $model common\models\Post */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="post-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'content')->textarea(['rows' => 6]) ?>

    <?= $form->field($model, 'tags')->textarea(['rows' => 6]) ?>

    <!--<?= $form->field($model, 'status')->textInput() ?>-->
        <?php
    	$array=Yii::$app->db->createCommand('select id,name from poststatus')->queryAll();
    
    	$allStatus=ArrayHelper::map($array,'id','name');
    	?>
    <?= $form->field($model, 'status')
    		->dropDownList($allStatus);?>

    <?= $form->field($model, 'create_time')->textInput() ?>

    <?= $form->field($model, 'update_time')->textInput() ?>
        <?php
//    	$adminuser=Adminuser::find()
        $adminuser=(new \yii\db\Query())
    	->select(['nickname','id'])//注意顺序**********
    	->from('adminuser')
    	->indexBy('id')
    	->column();
    	
    	?>
    <?= $form->field($model, 'author_id')
    	->dropDownList($adminuser); ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '新增' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
